package indi.dos;

import static org.junit.jupiter.api.Assertions.*;

import java.util.ArrayList;
import java.util.Date;
import java.util.Scanner;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import indi.entity.Card;
import indi.entity.Record;
import indi.entity.Title;
import indi.service.CardService;
import indi.service.RecordService;
import indi.service.TitleService;

class TestRecordService {

	@BeforeEach
	void setUp() throws Exception {
	}

	@AfterEach
	void tearDown() throws Exception {
	}

	@Test
	void test() {
		System.out.println("测试开始");
		Card card = new CardService().makeACard("合肥", "计算机专业");
		RecordService  rs = new RecordService();
		ArrayList<Title> titles = new ArrayList<>();
		ArrayList<Record> records = new ArrayList<>();
		
		titles.add(new Title("001", "作者1", 20, "书1", (float)23.5, "类型1"));
		titles.add(new Title("002", "作者2", 20, "书2", (float)253, "类型2"));
		titles.add(new Title("003", "作者3", 20, "书3", (float)23, "类型3"));
		titles.add(new Title("004", "作者4", 20, "书4", (float)233.5, "类型4"));

		
		rs.addRecords(card, titles);
		
		
		records = rs.getCurrentRecords();
		// 判断
		assertEquals(4, records.size());
		System.out.println("添加后");
		for(Record e: records) {
			System.out.println(e.toString());
		}
		while(true) {
			System.out.println("输入删除选项：");
			Scanner s = new Scanner(System.in);
			String id = s.next();
			rs.removeRecord(id);
			
			if(id.equals("end")) {
				break;
			}
//			ts.outputTitles(titles);
		}
		records = rs.getCurrentRecords();
		rs.outputRecords(records);
		System.out.println("测试结束");
	}

}
